<!doctype html>
<html class="no-js">
<script src="../js/head.js"></script>
<body>
<script src="../js/header.js"></script>
<div class="am-cf admin-main">
    <!-- sidebar start -->
    <script src="../js/sidebar.js"></script>
    <!-- sidebar end -->

    <!-- content start -->
    <div class="admin-content" id="content-body">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">账号资料</strong>
                </div>
            </div>

            <hr>

            <div class="am-g" align="center">
                <div class="am-u-sm-2"><br/></div>
                <div class="am-u-sm-8">
                    <form class="am-form" id="form" data-am-validator>
                        <legend><strong>个人资料</strong></legend>
                        <div class="am-u-sm-6">
                            <div class="am-form-group">
                                <label for="name">姓名：</label>
                                <input type="text" class="am-form-field" id="name" style="text-align: center" disabled/>
                            </div>
                            <div class="am-form-group">
                                <label for="username">用户名：</label>
                                <input type="text" class="am-form-field" id="username" style="text-align: center"
                                       disabled/>
                            </div>
                            <div class="am-form-group">
                                <label for="password2">确认密码：</label>
                                <input type="password" class="am-form-field" style="text-align: center" id="password2" data-equal-to="#password" required/>
                            </div>
                        </div>
                        <div class="am-u-sm-6">
                            <div class="am-form-group">
                                <label for="sex">性别：</label>
                                <input type="text" class="am-form-field" style="text-align: center" id="sex" disabled/>
                            </div>
                            <div class="am-form-group">
                                <label for="password">密码：</label>
                                <input type="password" class="am-form-field" style="text-align: center" id="password" required/>
                            </div>
                            <div class="am-form-group">
                                <br/>
                                <button type="button" class="am-btn am-btn-secondary am-round" onclick="mySubmit()">保存</button>
                            </div>
                        </div>
                        <hr/>
                    </form>
                </div>
                <div class="am-u-sm-2"><br/></div>

            </div>
            <script src="../js/footer.js"></script>
        </div>
        <!-- content end -->
    </div>

    <a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
       data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
</div>

<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提示</div>
        <div class="am-modal-bd" id="msg">
            修改成功！
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>
<script src="../js/util.js"></script>
<script>
    $(function () {
        $("#name").val(current.name);
        $("#sex").val(sexFormatter(current.sex));
        $("#username").val(current.username);
    });

    function mySubmit() {
        $.ajax({
            type: 'put',
            dataType: 'json',
            url: '../employee',
            data: {"id": current.uid, password: $("#password").val()},
            success: function (data) {
                if (data.success) {
                    $('#my-alert').modal('open')
                } else {
                    $.messager.show({    // show error message
                        title: 'Error',
                        msg: data.message
                    });
                }
            }
        });
    }

</script>
</body>
</html>
